<?php

include_once 'include\ServerInterface.php';
include_once 'base\DataBaseController.php';
include_once 'include\MessageController.php';
include_once 'include\Constans.php';
include_once 'include\ActionController.php';
include_once 'include\SearchController.php';
include_once 'xml\XmlFactory.php';
include_once 'nusoap/nusoap.php';

$namespace = "http://sanity-free.org/services";
$server = new soap_server();
$server->configureWSDL("ServerInterface");
$server->wsdl->schemaTargetNamespace = $namespace;

DataBaseController::connect();

//INTERFACE METHOD
function insertEventLocation($eventLocationName, $eventLocationAdres, $eventLocationCity, $eventLocationLocationName, $eventLocationDescription, $locationX, $locationY, $eventName, $eventDescription, $eventValue, $user, $tags, $categores) {	
	return ActionController::insertEventLocation($eventLocationName, $eventLocationAdres, $eventLocationCity, $eventLocationLocationName, $eventLocationDescription, $locationX, $locationY, $eventName, $eventDescription, $eventValue, $user, $tags, $categores);
}

function insertEvent($eventLocationId, $name, $description, $value, $user, $tag, $categoryId) {	
	return ActionController::insertEvent($eventLocationId, $name, $description, $value, $user, $tag, $categoryId);
}

function getTag() {	
	return ActionController::getTag();
}

function getCategory() {	
	return ActionController::getCategory();
}

function search($text, $valueMin, $valueMax) {	
	return ActionController::search($text, $valueMin, $valueMax);
}

/*
function deleteEventLocation($eventLocationId) {	
	return ActionController::deleteEventLocation($eventLocationId);
}

function deleteEvent($eventId) {	
	return ActionController::deleteEvent($eventId);
}
*/

$server->register(// register our WebMethod		
'insertEventLocation', // method name:
//array('name'=>'xsd:string', 'adress'=>'xsd:string', 'city'=>'xsd:string', 'location'=>'xsd:string', 'x'=>'xsd:float', 'y'=>'xsd:float', 'description'=>'xsd:string', 'marker'=>'xsd:string'), // parameter list:
array('eventLocationName'=>'xsd:string', 'eventLocationAdres'=>'xsd:string', 'eventLocationCity'=>'xsd:string', 'eventLocationLocationName'=>'xsd:string', 'eventLocationDescription'=>'xsd:string', 'locationX'=>'xsd:float', 'locationY'=>'xsd:float', 'eventName'=>'xsd:string', 'eventDescription'=>'xsd:string', 'eventValue'=>'xsd:string', 'user'=>'xsd:string', 'tags'=>'xsd:string', 'categores'=>'xsd:string'), // parameter list:
array('return'=>'xsd:string'), // return value(s):
$namespace, // namespace:
false, // soapaction: (use default)
'rpc', // style: rpc or document
'encoded', // use: encoded or literal
'insertEventLocation.'); // description: documentation for the method

$server->register(// register our WebMethod		
'insertEvent', // method name:
array('eventLocationId'=>'xsd:int', 'name'=>'xsd:string', 'description'=>'xsd:string', 'value'=>'xsd:string', 'user'=>'xsd:string', 'tag'=>'xsd:string', 'categoryId'=>'xsd:string'), // parameter list:
array('return'=>'xsd:string'), // return value(s):
$namespace, // namespace:
false, // soapaction: (use default)
'rpc', // style: rpc or document
'encoded', // use: encoded or literal
'insertEvent.'); // description: documentation for the method

$server->register(// register our WebMethod		
'getTag', // method name:
array(), // parameter list:
array('return'=>'xsd:string'), // return value(s):
$namespace, // namespace:
false, // soapaction: (use default)
'rpc', // style: rpc or document
'encoded', // use: encoded or literal
'getTag.'); // description: documentation for the method

$server->register(// register our WebMethod		
'getCategory', // method name:
array(), // parameter list:
array('return'=>'xsd:string'), // return value(s):
$namespace, // namespace:
false, // soapaction: (use default)
'rpc', // style: rpc or document
'encoded', // use: encoded or literal
'getCategory.'); // description: documentation for the method

$server->register(// register our WebMethod		
'search', // method name:
array('text'=>'xsd:string', 'valueMin'=>'xsd:float', 'valueMax'=>'xsd:float'), // parameter list:
array('return'=>'xsd:string'), // return value(s):
$namespace, // namespace:
false, // soapaction: (use default)
'rpc', // style: rpc or document
'encoded', // use: encoded or literal
'search.'); // description: documentation for the method

$POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';

$server->service($POST_DATA);

?>